home *** CD-ROM | disk | FTP | other *** search
/ Aminet 43 / Aminet 43 (2001)(GTI - Schatztruhe)[!][Jun 2001].iso / Aminet / dev / moni / SystemViewer.lha / Source / SysSemaphore.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-19  |  17.0 KB  |  674 lines

  1. /****h *SysSemaphore.c ************************************************
  2. **
  3. ** NAME
  4. **    SysSemaphore.c
  5. **
  6. ** DESCRIPTION
  7. **    Display a list of all Semaphores currently known to the OS.
  8. **
  9. ** FUNCTIONAL INTERFACE:
  10. **
  11. **
  12. **
  13. ** FUNCTIONS FROM SysCommon.c:
  14. **
  15. **   PUBLIC BOOL SanityCheck( char *msg, ULONG addr );
  16. **
  17. **   PUBLIC int  SetupSystemList( (*OpenWindowFunc)( void ) );
  18. **
  19. **   PUBLIC void ShutdownSystemList( void );
  20. **
  21. **   PUBLIC void ModifyListView( struct Gadget *lv, 
  22. **                               struct Window *w,
  23. **                               struct List   *list,
  24. **                               struct Gadget *strgadget
  25. **                             );
  26. **
  27. **  GUI Designed by : Jim Steichen
  28. **
  29. ***********************************************************************
  30. */
  31.  
  32. #include <string.h>
  33.  
  34. #include <exec/types.h>
  35. #include <exec/execbase.h>
  36.  
  37. #include <AmigaDOSErrs.h>
  38.  
  39. #include <intuition/intuition.h>
  40. #include <intuition/classes.h>
  41. #include <intuition/classusr.h>
  42. #include <intuition/imageclass.h>
  43. #include <intuition/gadgetclass.h>
  44.  
  45. #include <libraries/gadtools.h>
  46.  
  47. #include <graphics/displayinfo.h>
  48. #include <graphics/gfxbase.h>
  49.  
  50. #include <clib/exec_protos.h>
  51. #include <clib/intuition_protos.h>
  52. #include <clib/gadtools_protos.h>
  53. #include <clib/graphics_protos.h>
  54. #include <clib/utility_protos.h>
  55. #include <clib/diskfont_protos.h>
  56.  
  57. #include "CPGM:GlobalObjects/CommonFuncs.h"
  58.  
  59. #include "SysLists.h"
  60.  
  61. #define SemLV      0
  62. #define Update     1
  63. #define Remove     2
  64. #define Cancel     3
  65. #define Release    4
  66. #define SemDisplay 5
  67.  
  68. #define ATS_CNT 6
  69.  
  70. #define LISTVIEWGADGET ATSGadgets[ SemLV ]
  71. #define SEM_DISPLAY    ATSGadgets[ SemDisplay ]
  72.  
  73. PUBLIC struct List *SListPtr = NULL;
  74.  
  75. PRIVATE char ver[] = "$VER: SysSemaphore 1.0 (18-Sep-2000) by J.T. Steichen";
  76.  
  77. PRIVATE struct Window       *ATSWnd   = NULL;
  78. PRIVATE struct Gadget       *ATSGList = NULL;
  79. PRIVATE struct IntuiMessage  ATSMsg;
  80. PRIVATE struct Gadget       *ATSGadgets[ ATS_CNT ];
  81.  
  82. PRIVATE UWORD  ATSLeft   = 0;
  83. PRIVATE UWORD  ATSTop    = 16;
  84. PRIVATE UWORD  ATSWidth  = 632;
  85. PRIVATE UWORD  ATSHeight = 238;
  86. PRIVATE UBYTE *ATSWdt    = (UBYTE *) "System Semaphores Info:";
  87.  
  88. PUBLIC struct TextFont *ATSFont    = NULL;
  89.  
  90. #define MAXSEMS    30
  91. #define NODELENGTH 80
  92.  
  93. PRIVATE struct MinList SempList;
  94. PRIVATE struct Node    SempNode;
  95. PRIVATE struct Node    SempNodes[ MAXSEMS      ] = { NULL, };
  96. PRIVATE UBYTE          NodeStrs[  MAXSEMS * NODELENGTH ] = "";
  97.  
  98. PRIVATE UWORD ATSGTypes[] = {
  99.  
  100.    LISTVIEW_KIND, BUTTON_KIND, BUTTON_KIND,
  101.    BUTTON_KIND,   BUTTON_KIND, TEXT_KIND
  102. };
  103.  
  104. PRIVATE int SemLVClicked(   int whichitem );
  105. PRIVATE int UpdateClicked(  int dummy     );
  106. PRIVATE int RemoveClicked(  int dummy     );
  107. PRIVATE int CancelClicked(  int dummy     );
  108. PRIVATE int ReleaseClicked( int dummy     );
  109.  
  110. PRIVATE struct NewGadget ATSNGad[] = {
  111.  
  112.      2,   3, 627, 184,                NULL, NULL, SemLV, 
  113.    0, NULL, (APTR) SemLVClicked,
  114.    
  115.      2, 212,  71,  17, (UBYTE *) "_Update", NULL, Update, 
  116.    PLACETEXT_IN, NULL, (APTR) UpdateClicked,
  117.  
  118.    396, 212,  71,  17, (UBYTE *) "Remove",  NULL, Remove, 
  119.    PLACETEXT_IN, NULL, (APTR) RemoveClicked,
  120.  
  121.    554, 212,  71,  17, (UBYTE *) "_Cancel", NULL, Cancel, 
  122.    PLACETEXT_IN, NULL, (APTR) CancelClicked,
  123.  
  124.     82, 212,  71,  17, (UBYTE *) "Release", NULL, Release, 
  125.    PLACETEXT_IN, NULL, (APTR) ReleaseClicked,
  126.  
  127.      2, 190, 611, 16,                 NULL, NULL, SemDisplay, 
  128.    0, NULL, NULL
  129. };
  130.  
  131. PRIVATE ULONG ATSGTags[] = {
  132.  
  133.    GTLV_ShowSelected, NULL, 
  134.    LAYOUTA_Spacing,      2, TAG_DONE,
  135.  
  136.    GT_Underscore,      '_', TAG_DONE,
  137.    GA_Disabled,       TRUE, TAG_DONE,
  138.    GT_Underscore,      '_', TAG_DONE,
  139.    GA_Disabled,       TRUE, TAG_DONE,
  140.    GTTX_Border,       TRUE, TAG_DONE
  141. };
  142.  
  143. // -------------------------------------------------------------------
  144.  
  145. PRIVATE struct SignalSemaphore *CurrentSem = NULL;
  146.  
  147. PRIVATE int InitializeSemaphoreList( void )
  148. {
  149.    IMPORT struct ExecBase *SysBase;
  150.  
  151.    struct Task *tc = NULL;
  152.    char        *nm = NULL;
  153.    int          i  = 0;
  154.  
  155.    HideListFromView( LISTVIEWGADGET, ATSWnd );
  156.  
  157.    Forbid();
  158.  
  159.      SListPtr   = &SysBase->SemaphoreList;
  160.      CurrentSem = (struct SignalSemaphore *) SListPtr->lh_Head;
  161.  
  162.      while (i < MAXSEMS && CurrentSem != NULL)
  163.         {       
  164.         tc = CurrentSem->ss_Owner;
  165.         nm = CurrentSem->ss_Link.ln_Name;
  166.         
  167.         sprintf( &NodeStrs[ i++ * NODELENGTH ], 
  168.                  "%08LX %4d %4u %08LX %08LX %-20.20s %-30.30s",
  169.                  CurrentSem, 
  170.                  CurrentSem->ss_Link.ln_Pri,
  171.                  CurrentSem->ss_NestCount,
  172.                  &CurrentSem->ss_WaitQueue,
  173.                  CurrentSem->ss_QueueCount,
  174.                  nm == NULL ? "** NO NAME **" : nm,      
  175.                  tc == NULL ? "** UNKNOWN **" : tc->tc_Node.ln_Name
  176.                );
  177.         
  178.         CurrentSem = (struct SignalSemaphore *) 
  179.                       CurrentSem->ss_Link.ln_Succ;
  180.         }
  181.  
  182.      // Reset CurrentSem to the Head of the list.
  183.      CurrentSem = (struct SignalSemaphore *) SListPtr->lh_Head;
  184.  
  185.    Permit();
  186.  
  187.    GT_SetGadgetAttrs( LISTVIEWGADGET, ATSWnd, NULL,
  188.                       GTLV_Labels,       &SempList,
  189.                       GTLV_ShowSelected, SEM_DISPLAY,
  190.                       GTLV_Selected,     0, 
  191.                       GTLV_MaxPen,       255,
  192.                       GTLV_ItemHeight,   12,
  193.                       TAG_END
  194.                     );
  195.  
  196.    SetWindowTitles( ATSWnd, ATSWdt, (UBYTE *) -1 );
  197.  
  198.    return( i );
  199. }
  200.  
  201. PRIVATE char wt[80] = { 0, }, *modtitle = &wt[0];
  202.  
  203. PRIVATE int SemLVClicked( int whichitem )
  204. {
  205.    ULONG addr = 0L;
  206.  
  207.    if (whichitem == 0)
  208.       {
  209.       // Disable buttons because user selected the title item:
  210.  
  211.       GT_SetGadgetAttrs( ATSGadgets[ Remove ], ATSWnd, NULL,
  212.                          GA_Disabled, TRUE, TAG_DONE 
  213.                        );
  214.  
  215.       GT_SetGadgetAttrs( ATSGadgets[ Release ], ATSWnd, NULL,
  216.                          GA_Disabled, TRUE, TAG_DONE 
  217.                        );
  218.    
  219.       SetWindowTitles( ATSWnd, ATSWdt, (UBYTE *) -1 );
  220.       
  221.       GT_SetGadgetAttrs( SEM_DISPLAY, ATSWnd, NULL,
  222.                          GTTX_Text, (STRPTR) "",
  223.                          TAG_DONE
  224.                        );
  225.  
  226.       CurrentSem = NULL;
  227.  
  228.       return( (int) TRUE );
  229.       }
  230.  
  231.    // Now get address from the item:
  232.    
  233.    (void) stch_l( SempNodes[ whichitem ].ln_Name, (long *) &addr );
  234.    CurrentSem = addr;
  235.     
  236.    if (addr != NULL)
  237.       {
  238.       sprintf( modtitle, "%s  You Selected:  %08LX", ATSWdt, addr );
  239.       SetWindowTitles( ATSWnd, modtitle, (UBYTE *) -1 );
  240.       
  241.       GT_SetGadgetAttrs( SEM_DISPLAY, ATSWnd, NULL,
  242.                          GTTX_Text, 
  243.                          (STRPTR) &NodeStrs[ NODELENGTH * whichitem ],
  244.                          TAG_DONE
  245.                        );
  246.       }
  247.  
  248.    // Enable buttons because user selected a Semaphore from the ListView:
  249.  
  250.    GT_SetGadgetAttrs( ATSGadgets[ Remove ], ATSWnd, NULL,
  251.                       GA_Disabled, FALSE, TAG_DONE 
  252.                     );
  253.  
  254.    GT_SetGadgetAttrs( ATSGadgets[ Release ], ATSWnd, NULL,
  255.                       GA_Disabled, FALSE, TAG_DONE 
  256.                     );
  257.    
  258.    return( (int) TRUE );
  259. }
  260.  
  261. PRIVATE int UpdateClicked( int dummy )
  262. {
  263.    int i;
  264.    
  265.    for (i = 1; i <= MAXSEMS; i++)
  266.        NodeStrs[ i * NODELENGTH ] = '\0'; // Kill old ListView strings.
  267.  
  268.    if (InitializeSemaphoreList() <= 0)
  269.       {
  270.       // No Semaphores known to SysBase!!
  271.       SetReqButtons( "OKAY" );
  272.  
  273.       (void) Handle_Problem( "No Semaphores found!", "OS ERROR??", NULL );
  274.  
  275.       SetReqButtons( "CONTINUE|ABORT" );
  276.       }  
  277.  
  278.    GT_RefreshWindow( ATSWnd, NULL );
  279.  
  280.    return( (int) TRUE );
  281. }
  282.  
  283. PRIVATE void RemoveTheSemaphore( struct SignalSemaphore *ss )
  284. {
  285.    // We should probably check that the ss->ss_QueueCount is 0 first: 
  286.  
  287.    // ObtainSemaphoreList( SysBase->SemaphoreList );
  288.    // Forbid();
  289.  
  290.    //   RemSemaphore( ss );
  291.    //   ObtainSemaphore( ss );
  292.    //   ReleaseSemaphore( ss );
  293.  
  294.    // Permit();
  295.    // ReleaseSemaphoreList( SysBase->SemaphoreList );
  296.  
  297.    (void) Handle_Problem( "NOT Implemented yet!", 
  298.                           "User Information:", NULL
  299.                         );
  300.    return;
  301. }
  302.  
  303. PRIVATE int RemoveClicked( int dummy )
  304. {
  305.    /* Do a SanityCheck() before Removing the Semaphore: */
  306.  
  307.    // Check CurrentSem for a non-NULL value
  308.  
  309.    if (CurrentSem != NULL)
  310.       {
  311.       if (SanityCheck( "Are you SURE you want to Remove %08lx?" ) != FALSE)
  312.          {
  313.          RemoveTheSemaphore( CurrentSem );
  314.  
  315.          if (InitializeSemaphoreList() <= 0)
  316.             {
  317.             // No Semaphores known to SysBase!!
  318.             SetReqButtons( "OKAY" );
  319.  
  320.             (void) Handle_Problem( "No Semaphores found!", 
  321.                                    "OS ERROR??", NULL
  322.                                  );
  323.  
  324.             SetReqButtons( "CONTINUE|ABORT" );
  325.             }
  326.  
  327.          GT_RefreshWindow( ATSWnd, NULL );
  328.          }
  329.       }
  330.    else
  331.       {
  332.       // No Semaphores selected by the user:
  333.       SetReqButtons( "OKAY" );
  334.  
  335.       (void) Handle_Problem( "Select a Semaphores first!", 
  336.                              "USER ERROR:", NULL
  337.                            );
  338.  
  339.       SetReqButtons( "CONTINUE|ABORT" );
  340.  
  341.       return( (int) TRUE );
  342.       }
  343.  
  344.    return( (int) TRUE );
  345. }
  346.  
  347. PRIVATE void ReleaseTheSemaphore( struct SignalSemaphore *ss )
  348. {
  349.    // int i;
  350.  
  351.    // We should probably check that the ss->ss_QueueCount is 0 first: 
  352.  
  353.    // ObtainSemaphoreList( SysBase->SemaphoreList );
  354.  
  355.    // for (i = 0; i < ss->ss_NestCount; i++)
  356.    //    ReleaseSemaphore( ss );
  357.  
  358.    // ReleaseSemaphoreList( SysBase->SemaphoreList );
  359.  
  360.    (void) Handle_Problem( "NOT Implemented yet!", 
  361.                           "User Information:", NULL
  362.                         );
  363.    return;
  364. }
  365.  
  366. PRIVATE int ReleaseClicked( int dummy )
  367. {
  368.    /* Do a SanityCheck() before Releasing the Semaphore: */
  369.  
  370.    // Check CurrentSem for a non-NULL value
  371.  
  372.    if (CurrentSem != NULL)
  373.       {
  374.       if (SanityCheck( "Are you SURE you want to Release %08lx?" )!= FALSE)
  375.          {
  376.          ReleaseTheSemaphore( CurrentSem );
  377.  
  378.          if (InitializeSemaphoreList() <= 0)
  379.             {
  380.             // No Semaphores known to SysBase!!
  381.             SetReqButtons( "OKAY" );
  382.  
  383.             (void) Handle_Problem( "No Semaphores found!", 
  384.                                    "OS ERROR??", NULL
  385.                                  );
  386.  
  387.             SetReqButtons( "CONTINUE|ABORT" );
  388.             }
  389.  
  390.          GT_RefreshWindow( ATSWnd, NULL );
  391.          }
  392.       else
  393.          return( (int) TRUE );
  394.       }
  395.    else
  396.       {
  397.       // No Semaphores selected by the user:
  398.       SetReqButtons( "OKAY" );
  399.  
  400.       (void) Handle_Problem( "Select a Semaphores first!", 
  401.                              "USER ERROR:", NULL
  402.                            );
  403.  
  404.       SetReqButtons( "CONTINUE|ABORT" );
  405.  
  406.       return( (int) TRUE );
  407.       }
  408.  
  409.    return( (int) TRUE );
  410. }
  411.  
  412. PRIVATE void CloseATSWindow( void )
  413. {
  414.    if (ATSWnd != NULL)
  415.       {
  416.       CloseWindow( ATSWnd );
  417.       ATSWnd = NULL;
  418.       }
  419.  
  420.    if (ATSGList != NULL)
  421.       {
  422.       FreeGadgets( ATSGList );
  423.       ATSGList = NULL;
  424.       }
  425.  
  426.    if (ATSFont != NULL)
  427.       {
  428.       CloseFont( ATSFont );
  429.       ATSFont = NULL;
  430.       }
  431.  
  432.    return;
  433. }
  434.  
  435. PRIVATE int ATSCloseWindow( void )
  436. {
  437.    CloseATSWindow();
  438.    return( (int) FALSE );
  439. }
  440.  
  441. PRIVATE int CancelClicked( int dummy )
  442. {
  443.    return( ATSCloseWindow() );
  444. }
  445.  
  446.  
  447. PRIVATE int OpenATSWindow( void )
  448. {
  449.    struct NewGadget  ng;
  450.    struct Gadget    *g;
  451.    UWORD             lc, tc;
  452.    UWORD             wleft = ATSLeft, wtop = ATSTop, ww, wh;
  453.  
  454.    ComputeFont( Scr, Font, &CFont, ATSWidth, ATSHeight );
  455.  
  456.    ww = ComputeX( CFont.FontX, ATSWidth );
  457.    wh = ComputeY( CFont.FontY, ATSHeight );
  458.  
  459.    if ((wleft + ww + CFont.OffX + Scr->WBorRight) > Scr->Width)
  460.       wleft = Scr->Width - ww;
  461.  
  462.    if ((wtop + wh + CFont.OffY + Scr->WBorBottom) > Scr->Height)
  463.       wtop = Scr->Height - wh;
  464.  
  465.    if ( !(ATSFont = OpenDiskFont( Font )))
  466.       return( -5 );
  467.  
  468.    if ( !(g = CreateContext( &ATSGList )))
  469.       return( -1 );
  470.  
  471.    for (lc = 0, tc = 0; lc < ATS_CNT; lc++)
  472.       {
  473.       CopyMem( (char *) &ATSNGad[lc], (char *) &ng, 
  474.                (long) sizeof( struct NewGadget ) 
  475.              );
  476.  
  477.       ng.ng_VisualInfo = VisualInfo;
  478.       ng.ng_TextAttr   = Font;
  479.       ng.ng_LeftEdge   = CFont.OffX + ComputeX( CFont.FontX, 
  480.                                                 ng.ng_LeftEdge
  481.                                               );
  482.  
  483.       ng.ng_TopEdge    = CFont.OffY + ComputeY( CFont.FontY, 
  484.                                                 ng.ng_TopEdge
  485.                                               );
  486.                                               
  487.       ng.ng_Width      = ComputeX( CFont.FontX, ng.ng_Width );
  488.       ng.ng_Height     = ComputeY( CFont.FontY, ng.ng_Height );
  489.  
  490.       ATSGadgets[lc] = g = CreateGadgetA( (ULONG) ATSGTypes[lc], 
  491.                              g, 
  492.                              &ng, 
  493.                              (struct TagItem *) & ATSGTags[tc] );
  494.  
  495.       while (ATSGTags[tc])
  496.          tc += 2;
  497.  
  498.       tc++;
  499.  
  500.       if (NOT g)
  501.          return( -2 );
  502.       }
  503.  
  504.    if ( !(ATSWnd = OpenWindowTags( NULL,
  505.  
  506.                      WA_Left,        wleft,
  507.                      WA_Top,         wtop,
  508.                      WA_Width,       ww + CFont.OffX + Scr->WBorRight,
  509.                      WA_Height,      wh + CFont.OffY + Scr->WBorBottom,
  510.                      WA_IDCMP,       LISTVIEWIDCMP | BUTTONIDCMP
  511.                        | TEXTIDCMP | IDCMP_CLOSEWINDOW 
  512.                        | IDCMP_REFRESHWINDOW | IDCMP_VANILLAKEY,
  513.  
  514.                      WA_Flags,       WFLG_DRAGBAR | WFLG_DEPTHGADGET 
  515.                        | WFLG_CLOSEGADGET | WFLG_SMART_REFRESH 
  516.                        | WFLG_ACTIVATE | WFLG_RMBTRAP,
  517.                      
  518.                      WA_Gadgets,     ATSGList,
  519.                      WA_Title,       ATSWdt,
  520.                      WA_ScreenTitle, "System Info",
  521.                      TAG_DONE )) 
  522.       )
  523.       return( -4 );
  524.  
  525.    GT_RefreshWindow( ATSWnd, NULL );
  526.  
  527.    return( 0 );
  528. }
  529.  
  530. PRIVATE int ATSVanillaKey( int whichkey )
  531. {
  532.    int rval = TRUE;
  533.    
  534.    switch (whichkey)
  535.       {
  536.       case 'u':
  537.       case 'U':
  538.          UpdateClicked( 0 );
  539.          break;
  540.          
  541.       case 'c':
  542.       case 'C':
  543.       case 'q':
  544.       case 'Q':
  545.          rval = ATSCloseWindow();
  546.          break;
  547.       }
  548.  
  549.    return( rval );
  550. }
  551.  
  552. PRIVATE int HandleATSIDCMP( void )
  553. {
  554.    struct IntuiMessage *m;
  555.    int                  (*func)( int code );
  556.    BOOL running = TRUE;
  557.  
  558.    while (running == TRUE)
  559.       {
  560.       if ((m = GT_GetIMsg( ATSWnd->UserPort ) ) == NULL )
  561.          {
  562.          (void) Wait( 1L << ATSWnd->UserPort->mp_SigBit );
  563.          continue;
  564.          }
  565.  
  566.       CopyMem( (char *) m, (char *) &ATSMsg, 
  567.                (long) sizeof( struct IntuiMessage ) 
  568.              );
  569.  
  570.       GT_ReplyIMsg( m );
  571.  
  572.       switch (ATSMsg.Class)
  573.          {
  574.          case IDCMP_REFRESHWINDOW:
  575.             GT_BeginRefresh( ATSWnd );
  576.             GT_EndRefresh( ATSWnd, TRUE );
  577.             break;
  578.  
  579.          case IDCMP_CLOSEWINDOW:
  580.             running = ATSCloseWindow();
  581.             break;
  582.  
  583.          case IDCMP_VANILLAKEY:
  584.             running = ATSVanillaKey( ATSMsg.Code );
  585.             break;
  586.  
  587.          case IDCMP_GADGETUP:
  588.          case IDCMP_GADGETDOWN:
  589.             func = (void *) ((struct Gadget *) ATSMsg.IAddress)->UserData;
  590.             if (func != NULL)
  591.                running = func( (int) ATSMsg.Code );
  592.             break;
  593.          }
  594.       }
  595.  
  596.    return( running );
  597. }
  598.  
  599. PUBLIC int HandleSemaphoreLV( void )
  600. {
  601.    int i = 0;
  602.  
  603.    if (SetupSystemList( &OpenATSWindow ) < 0)
  604.       {
  605.       (void) Handle_Problem( "Couldn't open a System ListViewer!", 
  606.                              "Allocation Problem:", NULL 
  607.                            );
  608.       return( -1 );
  609.       }
  610.  
  611.    // Disable buttons until user selects a Semaphore from the ListView:
  612.  
  613.    GT_SetGadgetAttrs( ATSGadgets[ Remove ], ATSWnd, NULL,
  614.                       GA_Disabled, TRUE, TAG_DONE 
  615.                     );
  616.  
  617.    GT_SetGadgetAttrs( ATSGadgets[ Release ], ATSWnd, NULL,
  618.                       GA_Disabled, TRUE, TAG_DONE 
  619.                     );
  620.    
  621.    SempNode.ln_Succ = (struct Node *) SempList.mlh_Tail;
  622.    SempNode.ln_Pred = (struct Node *) SempList.mlh_Head;
  623.    SempNode.ln_Type = 0;
  624.    SempNode.ln_Pri  = MAXSEMS - 129;
  625.    SempNode.ln_Name = "Address   Pri Nest Queue    Count    Name"
  626.                       "                 Owner Task ";
  627.  
  628.    SempNodes[0]     = SempNode;
  629.  
  630.    SetNotifyWindow( ATSWnd ); // For Handle_Problem().
  631.   
  632.    // ScrNodes[0] is already set up:
  633.  
  634.    for (i = 1; i <= MAXSEMS; i++)
  635.        {
  636.        SempNodes[i].ln_Name = &NodeStrs[ i * NODELENGTH ];
  637.        SempNodes[i].ln_Pri  = MAXSEMS - i - 129;
  638.        }     
  639.  
  640.    NewList( (struct List *) &SempList );
  641.  
  642.    for (i = 0; i < MAXSEMS; i++)
  643.       Enqueue( (struct List *) &SempList, &SempNodes[i] );
  644.  
  645.    (void) InitializeSemaphoreList();
  646.  
  647.    GT_SetGadgetAttrs( LISTVIEWGADGET, ATSWnd, NULL,
  648.                       GTLV_Labels,       &SempList,
  649.                       GTLV_ShowSelected, SEM_DISPLAY,
  650.                       GTLV_Selected,     1,
  651.                       GTLV_MaxPen,       255,
  652.                       GTLV_ItemHeight,   12,
  653.                       TAG_END
  654.                     );
  655.  
  656.    GT_RefreshWindow( ATSWnd, NULL );
  657.  
  658.    (void) HandleATSIDCMP();
  659.    
  660.    ShutdownSystemList();
  661.    return( 0 );
  662. }
  663.  
  664. #ifdef DEBUG
  665.  
  666. PUBLIC int main( void )
  667. {
  668.    return( HandleSemaphoreLV() );
  669. }
  670.  
  671. #endif
  672.  
  673. /* --------------------- END of SysSemaphore.c file! --------------- */
  674.